package top.dreamyy.pattern.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import top.dreamyy.pattern.dao.PatternDao;
import top.dreamyy.pattern.dao.UserDao;
import top.dreamyy.pattern.domain.Menu;
import top.dreamyy.pattern.domain.Pattern;
import top.dreamyy.pattern.domain.User;
import top.dreamyy.pattern.service.PatternService;

@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
@Service("patternService")
public class PatternServiceImpl implements PatternService {

	@Autowired
	PatternDao patternDao;
	@Autowired
	UserDao userDao;
	
	@Override
	public Pattern select(int id) {
		System.out.println("select "+id);
		return patternDao.selectPattern(id);
	}
	
	
	@Override
	public User judgeUser(String name, String password) {
		return userDao.selecttUser(name, password);
	}


	@Override
	public void saveUser(String name, String password, String stuid) {
		System.out.println("1");
		userDao.insertUser(name, password, stuid);
	}


	@Override
	public User existUser(String name) {
		return userDao.existUser(name);
	}


	@Override
	public List<Menu> getMenu() {
		return patternDao.selectMenu();
	}


	@Override
	public int saveSugg(String sugg) {
		return patternDao.insertSugg(sugg);
	}
}
